package com.scpii.api.controller.user;

import javax.annotation.Resource;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.scpii.api.common.auth.password.UsersInfoDetailsService;
import com.scpii.api.common.base.BaseController;
import com.scpii.api.domain.auth.UsersInfoDetails;
import com.scpii.api.util.PrincipalUtil;

@Controller
@RequestMapping("/user/show")
public class ShowController extends BaseController {

	@Resource
	private UsersInfoDetailsService usersInfoDetailsService;

	@PreAuthorize("hasRole('ROLE_CLIENT')")
	@RequestMapping(method = RequestMethod.GET)
	@ResponseBody
	public UsersInfoDetails getUser() {
		return usersInfoDetailsService
				.loadUsersInfoDetailsByPrimaryKey(PrincipalUtil
						.getPrincipal().getId());
	}
}
